﻿using LearningEnglish.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace LearningEnglish.Controllers.Api
{
    public class UploadFileController : Controller
    {
        [AcceptExAjax]
        [NormalJson]
        public ActionResult UploadImg()
        {
            var upload = UploadFile.AcceptImgFile();
            upload.Save(Request.Files);
            var ids = new List<Guid>();
            foreach (var file in upload.SaveFiles)
            {
                ids.Add(FileService.Instance.GetFileID(Path.GetFileName(file)));
            }
            return Json(new { ids = ids }, JsonRequestBehavior.AllowGet);
        }
    }
}